import {abstractValidator} from "./abstractValidator";
import {mc_validatorResult} from "../model/mc_validatorResult";
/**
 * Created by ybjaa on 2017/6/29.
 */


/**
 *
 * 正则表达式匹配失败
 *
 */
export class regularFailValidator extends abstractValidator{

    protected regexp:RegExp=null;


    public setParameters(regxp:RegExp=null): void {
        this.regexp=regxp;
    }

    protected getValidator(value:string): mc_validatorResult {

        if(typeof(value) != "string"){
            this.setResult(false,"数据类型不对");
            this.result.result=false;
        }

        if(!this.regexp){
            this.setResult(false,"验证字符串为空");
        }

        if(this.regexp&&this.regexp.test(value)){
            return this.result;
        }

        this.setResult(false,"不符合规则");
        return this.result;
    }
}